package day1212zy;

import cn.itcast.xml.XmlUtils;

import java.util.List;

public class Test {
    public static void main(String[] args) throws Exception {
        List<Classes> classes = XmlUtils.readAll("src/day1212zy/classes.xml", Classes.class);
        List<Student> students = XmlUtils.readAll("src/day1212zy/student.xml", Student.class);
        for (Classes c : classes) {
            for (Student s : students) {
                if (c.getClassID().equals(s.getClassID())){
                    c.getList().add(s);
                }
            }
        }
        System.out.println(classes);
      /*  int num=0;
        double avg=0;*/
        /*HashMap<String,Integer> map = new HashMap<>();//班级id,班级总年龄
        for (Classes classes : list3) {
            for (Student student : classes.getClist()) {
               if (!map.containsKey(student.getClassesId())){
                   map.put(student.getClassesId(),student.getAge());
               }else{
                   map.put(student.getClassesId(),student.getAge()+map.get(student.getClassesId()));
               }
            }
        }


        for (Classes c : list3) {
            ss:for (Map.Entry<String, Integer> entry : map.entrySet()) {
                if (entry.getKey().equals(c.getClassesId())){
                    //班级id  总年龄      班级id   平均年龄
                    map.put(c.getClassesId(),entry.getValue()/c.getClist().size());
                    break ss;
                }
            }
        }
        double max=0.0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            for (Classes c : list3) {
                if (entry.getValue()<max){
                    System.out.println("平均年龄最大的班级编号是："+c.getClassesId()+"，班级名称是："+c.getClassesName()+",讲师是："+c.getTeacher()+",助理讲师是："+c.getAssistant()+"辅导员是："+c.getInstructor()+"平均年龄是："+entry.getValue());
                }
            }
        }
    }*/
    }
}
